cellrendererpix: save the icon size locally instead of in the helper
authorCosimo Cecchi <cosimoc@gnome.org>
Thu, 15 Dec 2011 18:59:24 +0000 (19:59 +0100)
committerCosimo Cecchi <cosimoc@gnome.org>
Thu, 15 Dec 2011 18:59:24 +0000 (19:59 +0100)
We need to save the icon size locally for GtkCellRendererPixbuf, since
its properties are set again every time it's drawn (resetting the icon
size on the helper by means of _gtk_icon_helper_clear() each time).

gtk/gtkcellrendererpixbuf.c

index 25820b3ac80634acbf17b8954ac2cc739344a175..6fec484dcee92b8fdc1a186a704c43eab7171045 100644 (file)
@@ -87,6 +87,7 @@ enum {
 struct _GtkCellRendererPixbufPrivate
 {
   GtkIconHelper *icon_helper;
+  GtkIconSize    icon_size;
 
   GdkPixbuf *pixbuf_expander_open;
   GdkPixbuf *pixbuf_expander_closed;
@@ -110,6 +111,7 @@ gtk_cell_renderer_pixbuf_init (GtkCellRendererPixbuf *cellpixbuf)
                                                   GtkCellRendererPixbufPrivate);
   priv = cellpixbuf->priv;
   priv->icon_helper = _gtk_icon_helper_new ();
+  priv->icon_size = GTK_ICON_SIZE_MENU;
 }
 
 static void
@@ -275,7 +277,7 @@ gtk_cell_renderer_pixbuf_get_property (GObject        *object,
       g_value_set_string (value, _gtk_icon_helper_get_stock_id (priv->icon_helper));
       break;
     case PROP_STOCK_SIZE:
-      g_value_set_uint (value, _gtk_icon_helper_get_icon_size (priv->icon_helper));
+      g_value_set_uint (value, priv->icon_size);
       break;
     case PROP_STOCK_DETAIL:
       g_value_set_string (value, priv->stock_detail);
@@ -350,10 +352,11 @@ gtk_cell_renderer_pixbuf_set_property (GObject      *object,
       break;
     case PROP_STOCK_ID:
       gtk_cell_renderer_pixbuf_reset (cellpixbuf);
-      _gtk_icon_helper_set_stock_id (priv->icon_helper, g_value_get_string (value), GTK_ICON_SIZE_MENU);
+      _gtk_icon_helper_set_stock_id (priv->icon_helper, g_value_get_string (value), priv->icon_size);
       break;
     case PROP_STOCK_SIZE:
-      _gtk_icon_helper_set_icon_size (priv->icon_helper, g_value_get_uint (value));
+      priv->icon_size = g_value_get_uint (value);
+      _gtk_icon_helper_set_icon_size (priv->icon_helper, priv->icon_size);
       break;
     case PROP_STOCK_DETAIL:
       g_free (priv->stock_detail);
@@ -361,14 +364,14 @@ gtk_cell_renderer_pixbuf_set_property (GObject      *object,
       break;
     case PROP_ICON_NAME:
       gtk_cell_renderer_pixbuf_reset (cellpixbuf);
-      _gtk_icon_helper_set_icon_name (priv->icon_helper, g_value_get_string (value), GTK_ICON_SIZE_MENU);
+      _gtk_icon_helper_set_icon_name (priv->icon_helper, g_value_get_string (value), priv->icon_size);
       break;
     case PROP_FOLLOW_STATE:
       priv->follow_state = g_value_get_boolean (value);
       break;
     case PROP_GICON:
       gtk_cell_renderer_pixbuf_reset (cellpixbuf);
-      _gtk_icon_helper_set_gicon (priv->icon_helper, g_value_get_object (value), GTK_ICON_SIZE_MENU);
+      _gtk_icon_helper_set_gicon (priv->icon_helper, g_value_get_object (value), priv->icon_size);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);